<?php

namespace App\Command;

use App\Service\MoneyService;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class FenHongShouYiCommand extends Command
{
    protected static $defaultName = 'fenHong';

    private $moneyService;
    public function __construct(MoneyService $moneyService)
    {
        $this->moneyService = $moneyService;
        parent::__construct();
    }

    protected function configure()
    {
        $this
            ->setDescription('用户理财账户的增值任务')
            ->addOption('action', null, InputArgument::OPTIONAL, '操作选项create：创建任务，deal:处理任务')
            ->addOption('line', null, InputOption::VALUE_NONE, '如果需要多线程执行输入线程号0-9，或者更大的区间')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output): int
    {
        $io = new SymfonyStyle($input, $output);
        $action = $input->getOption('action');

        if ($input->getOption('line')) {
            // ...
        }
        switch ($action) {
            case "create":
                $this->moneyService->crontabFenHongCreate();
                break;
            case "deal":
                $this->moneyService->cronTabFenHongDo();
                break;
            default:
        }
        $io->success('You have a new command! Now make it your own! Pass --help to see your options.');

        return 0;
    }
}
